<script type="text/javascript">//<![CDATA[
XHR.poll(1, '<%=url([[admin]], [[nas]], [[syncthing]], [[status]])%>', null,
	function(x, data) {
		var tb = document.getElementById('syncthing_status');
		if (data && tb) {
			if (data.running) {
				var links = '<font color=green>Syncthing <%:RUNNING%></font><input class="cbi-button mar-10" type="button" value="<%:Open Web Interface%>" onclick="openwebui();" />';
				tb.innerHTML = links;
			} else {
				tb.innerHTML = '<font color=red>Syncthing <%:NOT RUNNING%></font>';
			}
		}
	}
);

function openwebui(){                                                                                                                            
	var url = window.location.host+":<%=luci.sys.exec("uci -q get syncthing.config.port"):gsub("^%s*(.-)%s*$", "%1")%>";   
	window.open('http://'+url,'target','');                
};
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
	<p id="syncthing_status">
		<em><%:Collecting data...%></em>
	</p>
</fieldset>
